package com.mz.ozy.activity.me;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.mz.ozy.R;
import com.mz.ozy.base.BaseActivity;
import com.mz.ozy.bean.FriendBean;
import com.mz.ozy.bean.MyBounsBean;
import com.mz.ozy.bean.MyBounsRecodeBean;
import com.mz.ozy.bean.NewBonusBean;
import com.mz.ozy.bean.NewBonusDetailBean;
import com.mz.ozy.bean.NewBonusDonateBean;
import com.mz.ozy.bean.NewGQBean;
import com.mz.ozy.bean.NewResponeBean;
import com.mz.ozy.bean.PronotionBean;
import com.mz.ozy.mvp.presenter.MyBounsPresenter;
import com.mz.ozy.mvp.view.MyBonusContract;
import com.mz.ozy.utils.MD5Util;
import com.mz.ozy.utils.ToastUtils;
import com.mz.ozy.widget.dialog.PayPassDialog;
import com.mz.ozy.widget.dialog.PayPassView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MyBonusDonateActivity extends BaseActivity<MyBonusContract.View, MyBounsPresenter> implements MyBonusContract.View {

    @BindView(R.id.in_id)
    EditText inID;

    @BindView(R.id.et_amount)
    EditText etAmount;

    PayPassDialog dialog;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_bonus_donate);

        ButterKnife.bind(this);

        initView();
    }

    public void initView() {
        ButterKnife.bind(this);
        initTitle();
        tvTitle.setVisibility(View.GONE);
        tvCenterTitle.setText("账户转赠");
    }

    @OnClick({R.id.bt_confirm})
    public void onViewClicked(View view) {

        switch (view.getId()) {
            case R.id.bt_confirm:
            {
                String inidStr = inID.getText().toString().trim();
                if (TextUtils.isEmpty(inidStr)) {
                    ToastUtils.showToast(inID.getHint().toString().trim());
                    return;
                }
                String amountStr = etAmount.getText().toString().trim();
                if (TextUtils.isEmpty(amountStr)) {
                    ToastUtils.showToast(etAmount.getHint().toString().trim());
                    return;
                }

                dialog = new PayPassDialog(this);
                dialog.getPayViewPass().setForgetText(amountStr);
                dialog.getPayViewPass().setHintText("确认账号转赠");
                dialog.getPayViewPass()
                        .setPayClickListener(new PayPassView.OnPayClickListener() {
                            @Override
                            public void onPassFinish(String passContent) {
                                //6位输入完成回调
//                                mPresenter.onTb(MeWithActivity.this, type + "", accoun, money, MD5Util.getMD5String(passContent));
                                //String amount, String name, String account, String type
                                mPresenter.newBonusDonate(MyBonusDonateActivity.this, amountStr, inidStr, MD5Util.getMD5String(passContent));
                                dialog.dismiss();
                            }

                            @Override
                            public void onPayClose() {
                                dialog.dismiss();
                                //关闭回调
                            }

                            @Override
                            public void onPayForget() {
                                dialog.dismiss();
                                //点击忘记密码回调
                                startActivity(new Intent(MyBonusDonateActivity.this, PayPwdActivity.class));
                            }
                        });
            }
            break;

            default:
            {

            }
            break;
        }
    }

    @Override
    public void getInfoSuccess(MyBounsBean bean) {

    }

    @Override
    public void getInfoRecode(MyBounsRecodeBean bean) {

    }

    @Override
    public void getVipUpShSuccess(FriendBean bean) {

    }

    @Override
    public void getVipUpDataInfoSuccess(PronotionBean bean) {

    }

    @Override
    public void newBonusSuccess(NewBonusBean bean) {

    }

    @Override
    public void newBonusDetailSuccess(NewBonusDetailBean bean) {

    }

    @Override
    public void newBonusDonateSuccess(NewBonusDonateBean bean) {
        dialog.dismiss();

        if (bean == null) {
            ToastUtils.showToast("网络请求异常");
            return;
        }

        ToastUtils.showToast(bean.msg);
        finish();
    }

    @Override
    public void newGQSuccess(NewGQBean bean) {

    }
}